<style type="text/css">
.isforlong .col-sm-10 {
	margin-top: 10px; 
}
</style>
<div class="pageheader">
	<h2>
		<i class="fa fa-inbox"></i>库存管理
	</h2>
	<div class="breadcrumb-wrapper">
		<span class="label">你所在的位置：</span>
		<ol class="breadcrumb">
			<li><a href="/index">ERP管理系统</a></li>
			<li>库存管理</li>
			<li class="active">新增库存</li>
		</ol>
	</div>
</div>
<div class="contentpanel">
<div class="main">
<form action="/stock/add" method="post" class="form-horizontal">
    <?php if ($this->msg):?>
    <div style="margin: 20px 216px;"  class="form-group"><?php foreach ($this->msg as $v):?><span class="label label-warning"><?php echo $v;?></span><?php endforeach;?></div>
    <?php endif;?>  
    <div class="form-group form-inline">
        <label for="productname" class="col-sm-2 control-label">产品名称：</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="productname" size="58" value="<?php echo $this->title;?>">
        </div>
    </div>
    <div class="form-group form-inline">
        <label for="productenname" class="col-sm-2 control-label">英文标题：</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="productenname" size="58" value="<?php echo $this->entitle;?>">
        </div>
    </div>
    <div class="form-group form-inline">
        <label for="Sku" class="col-sm-2 control-label">Sku：</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" name="sku" size="58" value="<?php echo $this->sku;?>"></input>
        </div>
    </div>
    <div class="form-group">
        <label for="Category" class="col-sm-2 control-label">分类：</label>
        &nbsp;&nbsp;&nbsp;&nbsp;brand:
        <div class="btn-group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">请选择 <span class="caret"></span></button>
            <ul class="dropdown-menu" role="menu">
                <li><a href="#">brand1</a></li>
                <li><a href="#">brand2</a></li>
                <li><a href="#">brand3</a></li>
           </ul>
        </div>
        &nbsp;&nbsp;&nbsp;&nbsp;player:
        <div class="btn-group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">请选择 <span class="caret"></span></button>
            <ul class="dropdown-menu" role="menu">
                <li><a href="#">player1</a></li>
                <li><a href="#">player2</a></li>
                <li><a href="#">player3</a></li>
           </ul>
        </div>
    </div>
    <div class="form-group">
        <label for="content" class="col-sm-2 control-label">产品内容：</label>
        <div style="margin-bottom: 10px;margin-left: 200px;">
            <input style="width: 100px;" type="button" class="form-control" value="添加规格" onclick="addPatternSize(this);"></input>
		</div>
		<?php 
		$pattern_size = array('S','M','L','XL');//默认规格大小
		$pattern_size_stock = array('0','0','0','0');//默认库存为0
		$warning_value = array('0','0','0','0');//默认库存为0
		if(!empty($this->pattern_size)){$pattern_size=$this->pattern_size;}
		if(!empty($this->pattern_size_stock)){$pattern_size_stock=$this->pattern_size_stock;}
		if(!empty($this->warning_value)){$warning_value=$this->warning_value;}
		foreach ($pattern_size as $k=>$v){
		?>
		<div style="margin-bottom: 10px;margin-left: 200px;">
		        规格大小：
		    <input style="width: 100px;display: inline;" type="text" class="form-control" name="pattern_size[]" value="<?php echo $v;?>" size="15" />
			实际库存：
			<input style="width: 100px;display: inline;" type="text" class="form-control" name="pattern_size_stock[]" value="<?php echo $pattern_size_stock[$k];?>" size="10" />
			警告阀值：
			<input style="width: 100px;display: inline;" type="text" class="form-control" name="warning_value[]" size="10" value="<?php echo $warning_value[$k];?>" />
			<input style="width: 100px;display: inline;" type="button" class="form-control" onclick="deletePatternSize(this);" value="删除">
		</div>
		<?php }?>   
    </div>
    <div class="form-group isforlong">
        <label for="isforlong" class="col-sm-2 control-label">是否永不下架：</label>
        <div class="col-sm-10">
                        是：<input type="radio" name="is_forlong" value="1" checked="checked" ></input> 
			否：<input type="radio" name="is_forlong" value="0"></input>									
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default">提交</button>
        </div>
    </div>
</form>
</div>
</div>

<script>
function deletePatternSize(thisInput){
	$(thisInput).parent().remove();
}
function addPatternSize(thisInput){
	$(thisInput).parent().parent().append('<div style="margin-bottom: 10px;margin-left: 200px;">规格大小：&nbsp;<input style="width: 100px;display: inline;" type="text" class="form-control" name="pattern_size[]" value="" size="15"/>&nbsp;实际库存：&nbsp;<input style="width: 100px;display: inline;" type="text" class="form-control" name="pattern_size_stock[]" value="0" size="10"/>&nbsp;警告阀值：&nbsp;<input style="width: 100px;display: inline;" class="form-control" type="text" name="warning_value[]" size="10" />&nbsp;<input style="width: 100px;display: inline;" class="form-control" type="button" onclick="deletePatternSize(this);" value="删除"></div>');
}
</script>